Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify k6 load tests #5181

Merged
merged 15 commits into from
Nov 29, 2024
Merged

Modify k6 load tests #5181

merged 15 commits into from
Nov 29, 2024

Conversation

obulat
Copy link
Contributor

@obulat obulat commented Nov 25, 2024

Fixes

Fixes #5179 by @obulat

Description

The frontend k6 load test runs against the local Nuxt app on every CI run. Initially, when the test was added to run against the staging environment, it failed due to CPU limitations. To address this, we temporarily increased the staging CPU from 0.25 vCPU to 2 vCPU. However, our goal is to restore the staging environment to its previous resource levels while still reliably detecting potential memory leaks.

The k6 load tests run agains the locally-ran Nuxt app in the GitHub-hosted CI runners on every CI run, and then again after the PR is merged, against the Nuxt app deployed on staging. The GitHub-hosted CI runners use 4 CPU processor and 16 GB of RAM 1.

This PR adjusts the k6 test settings to maintain a constant request rate while preventing the tests from overwhelming the staging environment. It uses the constant-arrival-rate executor, which means that the rate of requests per seconds is constant, and does not depend on whether response was received or not.

After experimenting with different configurations, I think the following values will be a good start:

  • duration: 4-minute test is ensures that the load test completes within the CI pipeline timeframe, aligning with Playwright tests.
  • requests-per-second: I tried to lower this value 4 times, to match the required CPU usage in staging: from 7.28 rps to 1.72 rps. This was achieved by setting the rate for each scenario to 3 per minute. With six scenarios, this configuration results in an overall request rate of approximately 1.72 requests per second.

Here are some statistics from the k6 tests in staging, as well as the last 3 CI runs in this PR:

Metric Staging Environment GH CI Run 1 - Rate 30, Duration 5m GH CI Run 2 - Rate 10, Duration 5m GH CI Run 3 - Rate 3, Duration 4m
Requests Per Second (req/s) 7.28 req/s 16.05 req/s 5.39 req/s 1.72 req/s
Total Requests 4420 4832 1622 416
Total Test Duration ~10 minutes (607 seconds) ~5 minutes (301 seconds) ~5 minutes (301 seconds) ~4 minutes (240 seconds)
Average Request Time 3.47 seconds 153.4 milliseconds 140.08 milliseconds 197.71 milliseconds
Maximum Request Time 10.26 seconds 801.91 milliseconds 976.82 milliseconds 801.33 milliseconds
Dropped Iterations 235 0 0 0
Iterations 965 906 304 78
Iteration Rate 1.59 iterations/s 3.01 iterations/s 1.01 iterations/s 0.32 iterations/s

Deployment

For better testing how the k6 tests catch memory leaks and whether the new values are appropriate, I think the following process should be followed:

  1. Merge in the changes reverted in Fix frontend memory leak #4864, and see how the tests go in staging. We should see memory problems, manifested in either in a higher memory consumption in the AWS dashboard, or in the higher request timings/dropped iterations values.
  2. Merge in this PR to try to cap the CPU usage at 25% (since 25% of 2 vCPU should be equivalent to 100% of 0.25 vCPU). The values for the k6 tests should improve, but the memory leak should still be detectable.
  3. Revert the first change with the memory leak, confirm that the memory and CPU consumptions are within the lower limits of the staging values we want.
  4. Reduce the staging task resources.

Testing Instructions

Confirm that the deployment plan makes sense or suggest improvements.
Check the CI report for the load test and see that the requests per minutes are lower, and the test finishes within 4 minutes.

Checklist

  • My pull request has a descriptive title (not a vague title likeUpdate index.md).
  • My pull request targets the default branch of the repository (main) or a parent feature branch.
  • My commit messages follow best practices.
  • My code follows the established code style of the repository.
  • I added or updated tests for the changes I made (if applicable).
  • I added or updated documentation (if applicable).
  • I tried running the project locally and verified that there are no visible errors.
  • I ran the DAG documentation generator (ov just catalog/generate-docs for catalog
    PRs) or the media properties generator (ov just catalog/generate-docs media-props
    for the catalog or ov just api/generate-docs for the API) where applicable.

Developer Certificate of Origin

Developer Certificate of Origin
Developer Certificate of Origin
Version 1.1

Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
1 Letterman Drive
Suite D4700
San Francisco, CA, 94129

Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.


Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I
    have the right to submit it under the open source license
    indicated in the file; or

(b) The contribution is based upon previous work that, to the best
    of my knowledge, is covered under an appropriate open source
    license and I have the right under that license to submit that
    work with modifications, whether created in whole or in part
    by me, under the same open source license (unless I am
    permitted to submit under a different license), as indicated
    in the file; or

(c) The contribution was provided directly to me by some other
    person who certified (a), (b) or (c) and I have not modified
    it.

(d) I understand and agree that this project and the contribution
    are public and that a record of the contribution (including all
    personal information I submit with it, including my sign-off) is
    maintained indefinitely and may be redistributed consistent with
    this project or the open source license(s) involved.

Footnotes

  1. https://docs.github.com/en/actions/using-github-hosted-runners/using-github-hosted-runners/about-github-hosted-runners#standard-github-hosted-runners-for-public-repositories

@openverse-bot openverse-bot added 🧱 stack: frontend Related to the Nuxt frontend 🟧 priority: high Stalls work on the project or its dependents 🧰 goal: internal improvement Improvement that benefits maintainers, not users 💻 aspect: code Concerns the software code in the repository labels Nov 25, 2024
Copy link

github-actions bot commented Nov 25, 2024

Latest k6 run output1

     ✓ status was 200

     checks.........................: 100.00% ✓ 416      ✗ 0   
     data_received..................: 98 MB   408 kB/s
     data_sent......................: 54 kB   226 B/s
     http_req_blocked...............: avg=66.63µs  min=2.14µs   med=4.43µs   max=1.21ms   p(90)=160µs    p(95)=457.36µs
     http_req_connecting............: avg=24.95µs  min=0s       med=0s       max=1.16ms   p(90)=93.71µs  p(95)=111.76µs
     http_req_duration..............: avg=193.75ms min=28.82ms  med=159.77ms max=776.35ms p(90)=369.95ms p(95)=422.95ms
       { expected_response:true }...: avg=193.75ms min=28.82ms  med=159.77ms max=776.35ms p(90)=369.95ms p(95)=422.95ms
   ✓ http_req_failed................: 0.00%   ✓ 0        ✗ 416 
     http_req_receiving.............: avg=168.35µs min=53.99µs  med=129.58µs max=2.61ms   p(90)=270.77µs p(95)=343.58µs
     http_req_sending...............: avg=23.95µs  min=8.58µs   med=21.98µs  max=116.69µs p(90)=31.52µs  p(95)=44.06µs 
     http_req_tls_handshaking.......: avg=0s       min=0s       med=0s       max=0s       p(90)=0s       p(95)=0s      
     http_req_waiting...............: avg=193.56ms min=28.71ms  med=159.63ms max=776ms    p(90)=369.78ms p(95)=422.69ms
     http_reqs......................: 416     1.723953/s
     iteration_duration.............: avg=1.04s    min=603.24ms med=1.2s     max=1.98s    p(90)=1.36s    p(95)=1.39s   
     iterations.....................: 78      0.323241/s
     vus............................: 4       min=0      max=6 
     vus_max........................: 60      min=60     max=60

Footnotes

  1. This comment will automatically update with new output each time k6 runs for this PR

@obulat obulat self-assigned this Nov 25, 2024
@obulat obulat marked this pull request as ready for review November 25, 2024 13:32
@obulat obulat requested a review from a team as a code owner November 25, 2024 13:32
Copy link
Member

@krysal krysal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm eager to know the results of these tests!

@obulat obulat force-pushed the modify-k6-load-test branch 3 times, most recently from d7686eb to 3f56433 Compare November 29, 2024 05:18
@obulat obulat requested a review from a team as a code owner November 29, 2024 08:52
@obulat obulat merged commit 3a59f9b into main Nov 29, 2024
46 checks passed
@obulat obulat deleted the modify-k6-load-test branch November 29, 2024 09:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💻 aspect: code Concerns the software code in the repository 🧰 goal: internal improvement Improvement that benefits maintainers, not users 🟧 priority: high Stalls work on the project or its dependents 🧱 stack: frontend Related to the Nuxt frontend
Projects
Status: 🤝 Merged
Development

Successfully merging this pull request may close these issues.

Modify the staging k6 load testing to allow for accurate tests with lower resources
3 participants